home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8046 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: library.erc.clarkson.edu!rpi!not-for-mail
  2. From: P.v.Klaveren@bcs.cs.philips.com (Peter van Klaveren)
  3. Newsgroups: comp.lang.c++.moderated,comp.lang.c++
  4. Subject: enum expression is IF statement
  5. Date: 13 Feb 1996 14:32:12 -0000
  6. Organization: Philips Electronics BV.
  7. Sender: cppmods@netlab.cs.rpi.edu
  8. Approved: herbs@connobj.com
  9. Message-ID: <4fq7dc$pac@netlab.cs.rpi.edu>
  10. NNTP-Posting-Host: netlab.cs.rpi.edu
  11. X-Original-Date: Tue, 13 Feb 1996 07:23:27 GMT
  12.  
  13. enum
  14. {
  15.    CSEQ_IDLE,
  16.    CSEQ_ERROR,
  17.    CSEQ_ABORT,
  18.    CSEQ_WAIT4RESPONSE
  19. };
  20.  
  21. int state = 3;
  22.  
  23. if (state == CSEQ_WAIT4RESPONSE)
  24. {
  25.     // this code is not executed!!!
  26.     ...
  27. }
  28.  
  29. BOOL expr_is_valid = state == CSEQ_WAIT4RESPONSE;
  30.  
  31. if (expr_is_valid)
  32. {
  33.     // this code IS executed!!!
  34.     ...
  35. }
  36.  
  37.  
  38. I know it is not recommended to compare integers with enumeration
  39. values, but why on earth is 'expr_is_valid' TRUE but seems
  40. 'state == CSEQ_WAIT4RESPONSE' to result in FALSE (at least in a if
  41. expression calcuation)?
  42.  
  43. Anybody an idea?
  44.  
  45. Peter.
  46.                                              \\\//
  47.                                             -(o o)-
  48. ==========================================ooO-(_)-Ooo======
  49. Peter van Klaveren, E-mail: P.v.Klaveren@bcs.cs.philips.com
  50. ===========================================================
  51.  
  52.  
  53.       [ Articles to moderate: mailto:c++-submit@netlab.cs.rpi.edu ]
  54.       [  Read the C++ FAQ: http://www.connobj.com/cpp/cppfaq.htm  ]
  55.       [  Moderation policy: http://www.connobj.com/cpp/guide.htm  ]
  56.       [      Comments? mailto:c++-request@netlab.cs.rpi.edu       ]
  57.